<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>对象简写</title>
</head>
<body>
<script>
    function person(name, age) {
        //return {name:name,age:age};
        // 对象简写
        return {name, age};
    }

    // 调用和执行
    let json = person("小花花美美", 20);
    console.log(json.name, json.age);
    //========================= 实战应用 =========================
    // <button onclick="login()">登录</button>
    function login() {
        let username = $("#username").val();
        let password = $("#password").val();
        // 发送ajax
        $.ajax({
            type: "post",
            // 对象简写
            data: {username, password},
            // 原始写分
            //data:{username:username,password:password},
            success() {
            }
        });
    }
</script>
</body>
</html>